<?php
	class HtmlControl extends CommonControl{

		function index(){
			include './index/control/indexControl.php';
			$control = new IndexControl;
			$control->index();
			ob_start();
			$htmlData = ob_get_clean();
			if (file_put_contents('index.html', $htmlData)) {
				$this->success('首页生成成功');
			}else{
				$this->error("首页生成失败");
			}
		}

		function cat(){
			$db=M("category");
			$cat = $db->field('cathtml,cid,archtml,catdir')->all();
			$control = new indexControl;
			foreach ($cat as $c) {
				$caturl = get_cat_url($c,2);
				$path = dirname($caturl);
				is_dir($path) || dir_create($path);
				$_GET['cid'] = $c['cid'];
				ob_start();
				$control->cat();
				$data = ob_get_clean();
				file_put_contents($path . "index.html", $data);
			}
		}
	}
?>